package gemini.jsf;

import java.util.ArrayList;
import java.util.Collection;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;

public class RegisterForm {

    private String streetAddress;
    private String city;
    private String state;
    private String country;
    private static final String US = "United States";
    private static final String CANADA = "Canada";
    private static final String[] COUNTRY_NAMES = {US, CANADA};
    private static ArrayList<SelectItem> countryItems = null;

    // PROPERTY: countryNames
    public Collection getCountryNames() {
        if (countryItems == null) {
            countryItems = new ArrayList<SelectItem>();
            for (int i = 0; i < COUNTRY_NAMES.length; i++) {
                countryItems.add(new SelectItem(COUNTRY_NAMES[i]));
            }
        }
        return countryItems;
    }

    // PROPERTY: streetAddress
    public void setStreetAddress(String newValue) {
        streetAddress = newValue;
    }

    public String getStreetAddress() {
        return streetAddress;
    }

    // PROPERTY: city
    public void setCity(String newValue) {
        city = newValue;
    }

    public String getCity() {
        return city;
    }

    // PROPERTY: state
    public void setState(String newValue) {
        state = newValue;
    }

    public String getState() {
        return state;
    }

    // PROPERTY: country
    public void setCountry(String newValue) {
        country = newValue;
    }

    public String getCountry() {
        return country;
    }

    public void actionAddress(ActionEvent event) {
        System.out.println("ACTION IS CALLED");
    }

    public String registerAddress() {
        System.out.println("REGISTER");
        return "success";
    }
}
